Bug 1 & 5:WriteFileTool 范围校验(WriteFileTool.java 新增校验逻辑)#1084
Open
Fruank4 wants to merge 2 commits intoagentscope-ai:mainfrom
Open
Bug 1 & 5:WriteFileTool 范围校验(WriteFileTool.java 新增校验逻辑)#1084Fruank4 wants to merge 2 commits intoagentscope-ai:mainfrom
Fruank4 wants to merge 2 commits intoagentscope-ai:mainfrom
Conversation
parseRanges 本身保持宽松解析(兼容 ReadFileTool 的负数倒序索引),在 WriteFileTool 业务层增加明确校验:start < 1 或 start > end 时直接返回错误信息,防止行内容被重复写入。
Bug 2:预览路径不一致(FileToolUtils.java + WriteFileTool.java)
viewTextFile 签名从 String filePath 改为 Path path,调用方传入已验证的绝对路径,消除相对路径基于 CWD 解析导致读取到错误文件的问题。
Bug 3:ListHashUtil 采样 hash 漏检(ListHashUtil.java)
放弃 5 点采样 + String.hashCode() 的弱 hash,改为 SHA-256 全量遍历,任意位置元素变更都能被可靠检测,触发正确的全量重写而非增量追加。
Bug 4:范围替换换行不一致(WriteFileTool.java)
将 String.join("\n", newContent) + Files.writeString 改为 Files.write(path, newContent, charset),与 insertTextFile 保持一致,使用系统换行符,并保留文件末尾换行符。
Bug 6:urlToInputStream 传 null NPE(MediaUtils.java)
在方法入口增加 null/blank 检查,改为抛 IOException 而非无声 NPE,调用方可正常 catch 处理。
|
lichuang34 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
lichuang34 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Author
|
some dangerous check~ |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug1: parseRanges 本身保持宽松解析(兼容 ReadFileTool 的负数倒序索引),在 WriteFileTool 业务层增加明确校验:start < 1 或 start > end 时直接返回错误信息,防止行内容被重复写入。
Bug 2:预览路径不一致(FileToolUtils.java + WriteFileTool.java) viewTextFile 签名从 String filePath 改为 Path path,调用方传入已验证的绝对路径,消除相对路径基于 CWD 解析导致读取到错误文件的问题。
Bug 3:ListHashUtil 采样 hash 漏检(ListHashUtil.java)
放弃 5 点采样 + String.hashCode() 的弱 hash,改为 SHA-256 全量遍历,任意位置元素变更都能被可靠检测,触发正确的全量重写而非增量追加。
Bug 4:范围替换换行不一致(WriteFileTool.java)
将 String.join("\n", newContent) + Files.writeString 改为 Files.write(path, newContent, charset),与 insertTextFile 保持一致,使用系统换行符,并保留文件末尾换行符。
Bug 6:urlToInputStream 传 null NPE(MediaUtils.java) 在方法入口增加 null/blank 检查,改为抛 IOException 而非无声 NPE,调用方可正常 catch 处理。